package com.haiwen.boot.controller;
import com.github.pagehelper.PageInfo;
import com.haiwen.boot.pojo.BlogWithBLOBs;
import com.haiwen.boot.pojo.Poetry;
import com.haiwen.boot.service.HomePageService;
import com.haiwen.boot.vo.responseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;


@RestController
@Api(tags = "首页展示")
public class homePageController {
    @Autowired
    HomePageService service;
    //@RequiresRoles(logical = Logical.OR, value = {"user", "admin"})
    @GetMapping(value = "/poetry")
    @ApiOperation(value = "首页打字机效果")
    public Poetry PoetryShow(){
       return service.randomPoetry();
    }
    @GetMapping(value = "/homeBlog")
    @ApiOperation(value = "首页文章数据的展示")
    public responseData<BlogWithBLOBs> blogShow(@ApiParam("页数") @RequestParam int pageNum, @ApiParam("是否显示")@RequestParam Boolean isShow){
        List<BlogWithBLOBs> listBlogs = service.blogShow(pageNum,3,isShow);
        long total = new PageInfo<>(listBlogs).getTotal();
        return new responseData<>(200, "成功", listBlogs);
    }

}
